//约定一个通用的键名
const INFO_KEY = 'user'

//获取个人信息
export const getInfo = () =>{
    const defaultObj = { 
        token:'',
        userId:'',
        roleId:'',
        storeId:'',
        name:'',
        username:'',
        id:'',
        avatar:'https://web-kotori.oss-cn-beijing.aliyuncs.com/026b3312-1eb1-48c1-8059-d4e1744e06e3.jpg'
    }
    const result = localStorage.getItem(INFO_KEY)
    return result ? JSON.parse(result) : defaultObj
}

//设置个人信息
export const setInfo = (obj) =>{
    localStorage.setItem(INFO_KEY,JSON.stringify(obj))
}

//移除个人信息
export const removeInfo = () =>{
    localStorage.removeItem(INFO_KEY)
}